import Vue from 'vue'
import Router from 'vue-router'
import BasicLayout from '@/views/layouts/BasicLayout'
// import GeminiScrollbar from 'vue-gemini-scrollbar'
import index from './views/index.vue'

Vue.use(Router)
// Vue.use(GeminiScrollbar)

const router = new Router({
  mode: 'history',
  base: process.env.BASE_URL,

  routes: [
    {
      path: '/',
      redirect: '/index'
    },
    {
      path: '/index',
      component: BasicLayout,
      children: [
        {
          path: '',
          name: 'index',
          component: index //使用同步加载 使首页面渲染更快，减少白屏时间
          // component: () => import('./views/Index.vue') 
        }
      ]
    }
    , {
      path: '/deviceparameters',
      component: BasicLayout,
      children: [
        {
          path: '',
          name: 'deviceparameters',
          component: () => import('./views/deviceparameters.vue')
        }
      ]
    }
    , {
      path: '/test',
      component: BasicLayout,
      children: [
        {
          path: '',
          name: 'test',
          component: () => import('./views/test.vue')
        }
      ]
    }
    , {
      path: "*",
      redirect: '/index'
    }

  ]
})

//路由守卫
/* router.beforeEach((to, from, next) => {
  const isLogin = localStorage.SET_USER ? true : false
  if (to.path === '/login') {
    next()
  } else {
    // if (!(store.getters.user.User_Name) && Boolean(localStorage.SET_USER)) {
    //   store.dispatch("set_user", JSON.parse(localStorage.SET_USER));
    // }

    isLogin ? next() : next('/login')
  }

}) */

export default router
